# A simple window with the logo image on the left and a scrollable text window on the right
# 

#use Wx 0.15 qw[:allclasses];
#use strict;
package wxAbout;
#use Wx qw[:everything];
use Wx qw[wxTE_MULTILINE wxTE_READONLY wxDefaultSize wxDefaultPosition wxCB_DROPDOWN wxCB_READONLY wxTAB_TRAVERSAL wxGA_HORIZONTAL wxDEFAULT_FRAME_STYLE wxFULL_REPAINT_ON_RESIZE wxICON_ERROR wxOK wxBITMAP_TYPE_PNG wxBITMAP_TYPE_ANY wxNOT_FOUND wxALIGN_RIGHT wxALIGN_CENTER_VERTICAL wxEXPAND wxTOP wxBOTTOM wxALIGN_CENTER_HORIZONTAL wxALIGN_BOTTOM wxALL wxVERTICAL wxHORIZONTAL wxRIGHT wxTEXT_ALIGNMENT_CENTRE wxTEXT_ALIGNMENT_JUSTIFIED wxTEXT_ALIGNMENT_LEFT wxICON_INFORMATION wxFRAME_FLOAT_ON_PARENT wxCLOSE_BOX wxALIGN_CENTRE wxLEFT wxID_OK wxCENTRE wxSYS_COLOUR_BACKGROUND wxSOLID];
our @ISA = ("Wx::Dialog");
#use strict;
use Wx::RichText;
use MyImages;
sub new {
    my( $self, $parent, $id, $title, $pos, $size, $style, $name ) = @_;

    #Set default arguments
    $parent = undef                 unless defined $parent;
    $id     = -1                    unless defined $id;
    $pos    = wxDefaultPosition     unless defined $pos;
    $size   = Wx::Size->new(750,400)unless defined $size;
    $name   = ""                    unless defined $name;
    $style = wxFRAME_FLOAT_ON_PARENT | wxCLOSE_BOX unless defined $style;

    #If the panel is resized a full redraw is necessary
    $style = $style | wxFULL_REPAINT_ON_RESIZE;

    #call the constructor of the wxPanel.
    $self = $self->SUPER::new( $parent, $id, $title, $pos, $size, $style, $name );

	$self->{sizer} = Wx::BoxSizer->new(wxHORIZONTAL);
	$self->{sizer_right} = Wx::BoxSizer->new(wxVERTICAL);
	$self->SetSizer($self->{sizer});
	
	#The image
	$self->{panel} = Wx::Panel->new($self);
        my $bitmap = Wx::Bitmap->new(MyImages::load_image("darwin_tree_md.png"),wxBITMAP_TYPE_PNG);
        $self->{panel}->SetMinSize(Wx::Size->new($bitmap->GetWidth,$bitmap->GetHeight));
	$self->{sizer}->Add($self->{panel},0,wxALIGN_CENTRE|wxLEFT,10);
	$self->{sizer}->Add($self->{sizer_right},1,wxEXPAND|wxALL,5);

	$self->{text} = Wx::RichTextCtrl->new($self);
	$self->{text}->SetEditable(0);
	$self->{text}->SetBackgroundColour($self->GetBackgroundColour);
	$self->{button} = Wx::Button->new($self,wxID_OK,'');
	$self->{sizer_right}->Add($self->{text},1,wxEXPAND|wxALL,5);
	$self->{sizer_right}->Add($self->{button},0,wxCENTRE|wxALL,5);
	
    #Register the painting event
    Wx::Event::EVT_PAINT($self->{panel},  \&OnPaint);

    bless $self, 'wxAbout';
    return $self;
}

sub get_text {
	my $self = shift;
	return $self->{text};	
}

sub OnPaint {
    my ($self, $event) = @_;
 	$event->Skip();
    my $drawArea;

    #Depending whether the event is being called due to a change in the tree and 
    #not a redraw event we use different DC objects. Unsure how important this 
    #really is
    if (defined $event)
    {
        $drawArea = Wx::PaintDC->new($self);
    } else {
        $drawArea = Wx::ClientDC->new($self);
    }

    #Get the default background colour
    my $backColour = Wx::SystemSettings::GetColour(wxSYS_COLOUR_BACKGROUND);
    #$backColour = wxBLACK;
    #Create a brush with that colour
    my $brush = Wx::Brush->new($backColour, wxSOLID);
    #Set the brush as the default background brush
    $drawArea->SetBackground($brush);
    #Clear the panel
    $drawArea->Clear;
    my $bitmap = Wx::Bitmap->new(MyImages::load_image("darwin_tree_md.png"),wxBITMAP_TYPE_PNG);
    $drawArea->DrawBitmap($bitmap,0,0,0);

}

1;